package com.maimao.model.echarts.common;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

/**
 * @author MaoLin Wang
 * @date 2021/3/28 11:07 上午
 */

public abstract class EchartsOption<T> {

    /**
     * 导航栏
     */
    private List<String> legend;

    /**
     * 类型 bar line pie等
     */
    private String seriesType;

    /**
     * 系列数据
     */
    private List<SeriesData<T>> series;

    public abstract String getSeriesType();

    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class SeriesData<T> {
        private String name;
        private List<T> data;
        private String type;
        /**
         * 柱状+折线时 需指定y轴index 示例地址：https://echarts.apache.org/examples/zh/editor.html?c=mix-line-bar
         */
        private Integer yAxisIndex;


        @Override
        public String toString() {
            return "SeriesData{" +
                    "name='" + name + '\'' +
                    ", data=" + data +
                    ", type='" + type + '\'' +
                    '}';
        }
    }

    public List<String> getLegend() {
        return legend;
    }

    public void setLegend(List<String> legend) {
        this.legend = legend;
    }

    public void setSeriesType(String seriesType) {
        this.seriesType = seriesType;
    }

    public List<SeriesData<T>> getSeries() {
        return series;
    }

    public void setSeries(List<SeriesData<T>> series) {
        this.series = series;
    }
}
